﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PlutoStudio.Data.Common
{
    internal static class ConnectionStringPool
    {
        public static string GetConnectionString(int id)
        {
            return Configuration.ConfigurationManager.ConnectionPool.Connections[id].ConnectionString;
        }
    }

    internal static class SqlClientProviderFactory
    {
        private static Lazy<ISqlClientProvider> lazy = new Lazy<ISqlClientProvider>(GetProvider, System.Threading.LazyThreadSafetyMode.ExecutionAndPublication);

        public static ISqlClientProvider Provider
        {
            get
            {
                return lazy.Value;
            }
        }
        private static ISqlClientProvider GetProvider()
        {
            var typeName = Configuration.ConfigurationManager.ConnectionPool.SqlClientProvider;
            var type = Type.GetType(typeName);
            return Activator.CreateInstance(type) as ISqlClientProvider;
        }
    }
}
